<?php
if (!defined("IN_OP"))
{
    exit("You can't access this file directly...");
}
$gametype = intval(getvar("gametype"));
if ($curruser['prev_id'] != 0)
{
    exit();
}
$gType = chkGametype($gametype);
switch ($gType)
{
    case 0 :
        $ui = new UI();
        include( "admin_menu.php" );
        break;
    default :
        include_once( "class_3d/CheckMode_3d.php" );
        $chk = new CheckMode_3d($curruser['acl'], 1, $gametype);
        $chk->checkShow3dPage();
        unset($chk);
        $ui = new UI_3D();
        $jslink = "<script language=\"JScript.Encode\" src=\"site.js\"></script>" . ( "<script language=\"VBScript.Encode\" src=\"site.vbs\"></script>" );
        $ui->set("jslink", $jslink);
        $ui->header();
        include( "admin_menu_3d.php" );
        break;
}
$conf = new Config();
if ($conf->get("calcbet") == 1 || $conf->get("calcbet_3d") == 1 || $conf->get("calcbet_3t") == 1 || $conf->get("calcbet_3s1") == 1 || $conf->get("calcbet_3s2") == 1 || $conf->get("calcbet_3s3") == 1 || $conf->get("calcbet_3s4") == 1 || $conf->get("calcbet_3s5") == 1 || $conf->get("calcbet_3s6") == 1 || $conf->get("calcbet_5h") == 1 || $conf->get("calcbet_8h") == 1 || $conf->get("calcbet_8h2") == 1 || $conf->get("calcbet_8h3") == 1)
{
    $ui->showErrorPage("<p class=error>已经在颁奖过帐中，无法删除注单！</p>");
    exit();
}
$dt1 = getvar("dt1");
$dt2 = getvar("dt2");
$dt3 = "";
$OnlyBettotal = isset($_POST['chkbxOnlyBettotal']);
if ($OnlyBettotal)
{
    foreach ($g_gametype_3d as $gameid => $val)
    {
        $tbl = "_" . $g_gametype_3d[$gameid]['en'];
        $sql = "select concat('DROP TABLE ', group_concat(table_name)) From (SELECT table_name FROM information_schema.tables where table_schema='" . G_DBDATABASE . "' and table_name like 'bettotal{$tbl}%' LIMIT 30) A";
        $rs = getdb($sql);
        $sql = $rs->f[0];
        if (20 < strlen($sql))
        {
            getdb($sql);
            echo "<br><p><font color=red><b>Bettotal" . $tbl . " 资料表删除完成！</b></font></p>";
        }
        else
        {
            echo "<br><p><font color=red><b>作业完成,未删除 " . $tbl . " 资料表！</b></font></p>";
        }
    }
    $rs = getdb("SELECT count(table_name) FROM information_schema.tables where table_schema='" . G_DBDATABASE . "' and table_name like 'bettotal_%'");
    if ($rs)
    {
        echo "<br><p><font color=red><b>尚有 " . $rs->f[0] . " 个bettotal_资料表未删除！</b></font></p>";
    }
}
else
{
    echo "<form action=\"op.php?op=admin&fp=dbdel_bettotal\" method=post >";
    echo "<table border=1 cellpadding=0 cellspacing=0>";
    echo "<p><input type=checkbox name=chkbxOnlyBettotal >删除前30个 Bettotal 统计资料表";
    echo "<p>※ 所有注单统计资料表 bettotal_xx ,包含六合,时时彩等快开彩。</p>";
    echo "<input type=hidden name=gametype value=\"{$gametype}\">";
    echo "<p><input type=submit value=确定> <input type=button value=放弃 onclick=\"location.href='op.php?op=admin&fp=dbdel_bettotal&gametype={$gametype}'\">";
    echo "</form>";
}
echo "</body></html>";
?>